<?php

/**
 * 消息列表
 */

namespace app\member\api;

use \app\member\api\MemberApi;

class NoticeApi extends MemberApi {

    /**
     * 收藏
     */
    public function index() {

        $pageLimit = $this->data['limit'] ? $this->data['limit'] : 10;

        $where = [];
        $where['A.user_id'] = $this->userId;

        $model = target('member/MemberNotice');
        $count = $model->countList($where);
        $pageData = $this->pageData($count, $pageLimit);
        $list = $model->loadList($where, $pageData['limit'], 'notice_id desc');

        if ($list) {
            $this->success('ok', [
                'data' => $list,
                'pageData' => [
                    'pageLimit' => $pageLimit,
                    'limit' => count($list),
                    'page' => $pageData['page'],
                    'totalPage' => $pageData['totalPage']
                ]
            ]);
        } else {
            $this->error('暂无更多记录', 404);
        }


    }

}